#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/10/26 15:01
# @Author  : Crissu
# @Site    : 
# @File    : drawPic.py
# @Software: PyCharm
import xlrd, os, re, xlwt

# def readLstXls(path):
#     '''
#     :param path: .xls 路径
#     :return: None
#     '''
#     workbook = xlrd.open_workbook(path)  # 打开工作簿
#     sheets = workbook.sheet_names()  # 获取工作簿中的所有表格
#     worksheet = workbook.sheet_by_name(sheets[0])  # 获取工作簿中所有表格中的的第一个表格
#     idx2classMap = {}  # key:分类；value:正确个数
#     # 计算正确个数和分类总个数
#     for i in range(0, worksheet.nrows):
#         idx = int(worksheet.cell_value(i, 0))
#         name = str(worksheet.cell_value(i, 2)).split("\\")[0]
#         idx2classMap[idx] = name
#     print(idx2classMap)
#
# book_name_xls = 'test.xls'
# readLstXls(book_name_xls)

class_85_path = "C:/sjj/workspace/dataset/linyehaichong/croped_selected85_resized/"
names_85 = os.listdir(class_85_path)

class_180_path = "C:/sjj/workspace/dataset/linyehaichong/linyehaichong_raw/"
names_180 = os.listdir(class_180_path)
map_180names = {}
map_yw2zh = {}

zh_names_list = list()
yw_names_list = list()

for item in names_180:
    item180 = re.sub("\D", "", item)
    map_180names[item180] = item[len(item180):]

for item in names_85:
    item85 = re.sub("\D", "", item)
    map_yw2zh[item] = map_180names[item85]
    yw_names_list.append(item)
    zh_names_list.append(map_180names[item85])

print(map_yw2zh)
print(zh_names_list)
print(len(zh_names_list))
print(yw_names_list)
print(len(yw_names_list))
print(map_180names["1"])
print(map_180names["5"])
print(map_180names["61"])
print(map_180names["57"])





###########################
####    写入excel      ####
##########################
# # 创建一个工作簿
# xls = xlwt.Workbook()
# # 实例化一个工作表
# sht1 = xls.add_sheet("sheet1")
# # 表头
# sht1.write(0, 0, 'number')
# sht1.write(0, 1, '类名')
# sht1.write(0, 2, '数量')
# for i in range(85):
#     sht1.write(i+1, 0, i)
#     sht1.write(i+1, 1, zh_names_list[i])
#     length = len(os.listdir(class_85_path + yw_names_list[i] + "/"))
#     sht1.write(i+1, 2, length)
#
# xls.save("Table_ClassNames_Chinese.xls")



# m = {}
# m['a'] = 1
# m['b'] = 2
# for v in m:
#     print(v)





































